package com.njbdqn.ALi.zjg.dao;

import java.util.List;

import org.njbdqn.ali.database.SqlTemplate;

import com.njbdqn.ALi.zjg.entity.PageHelper;
import com.njbdqn.ALi.zjg.vo.SendCommentVO;

public class SendCommentDAO {
	private SqlTemplate template;
	private PageHelper helper;
	public SendCommentDAO(){
		template = new SqlTemplate();
		helper = new PageHelper();
	}

	public List<SendCommentVO> findAll(int account){
		String sql="select book_name,commentcontent,commenttime from books b,comment c "
				+ " where b.book_id=c.book_id and account=? order by commenttime desc limit 0,10";
		return template.resultToArray(sql, new Object[]{account}, SendCommentVO.class);
	}
	public PageHelper findPage(int cp,int pageSize,int account){
		helper.setPage(cp);
		helper.setSize(pageSize);
		String sql="select book_name,commentcontent,commenttime from books b,comment c "
				+ " where b.book_id=c.book_id and account=? order by commenttime desc ";
		return helper.getBean(sql, new Object[]{account}, SendCommentVO.class);
	}
}
